package com.flnet.spsys.controller;

import com.flnet.spsys.entity.GoodsEntity;
import com.flnet.spsys.service.IGoodsService;
import com.flnet.spsys.utils.ResultJson;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController extends BaseController{
    @Autowired
    IGoodsService iGoodsService;

    @ApiOperation(value = "商品信息",notes = "获取商品信息")
    @ApiResponses(
            @ApiResponse(code = 200,message = "获取成功",response = ResultJson.class)
    )
    @ResponseBody
    @GetMapping("/info")
    @CrossOrigin
    public Object getGoodsInfo(){
        List<GoodsEntity> list = iGoodsService.list();
        return ResultJson.success(list);
    }

    @GetMapping("/addGoods")
    public ResultJson addGoods(GoodsEntity goodsEntity){
        goodsEntity.getId();
        goodsEntity.getCategoryId();
        goodsEntity.getName();
        iGoodsService.save(goodsEntity);
        return ResultJson.success(null);
    }

}
